import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '供应商名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '产地',
    align: 'center',
    dataIndex: 'originPlace',
  },
  {
    title: '联系电话',
    align: 'center',
    dataIndex: 'contactPhone',
  },
  {
    title: '银行账户',
    align: 'center',
    dataIndex: 'bankAccount',
  },
  {
    title: '备注',
    align: 'center',
    dataIndex: 'remarks',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '供应商名称',
    field: 'name',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '产地',
    field: 'originPlace',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    label: '联系电话',
    field: 'contactPhone',
    component: 'JInput',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '供应商名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '产地',
    field: 'originPlace',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: true, message: '请输入产地!' }];
    },
  },
  {
    label: '联系电话',
    field: 'contactPhone',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false }, { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!' }];
    },
  },
  {
    label: '银行账户',
    field: 'bankAccount',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [{ required: false }, { pattern: '^\d{12,19}$', message: '不符合校验规则!' }];
    },
  },
  {
    label: '备注',
    field: 'remarks',
    component: 'InputTextArea',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  name: { title: '供应商名称', order: 0, view: 'text', type: 'string' },
  originPlace: { title: '产地', order: 1, view: 'text', type: 'string' },
  contactPhone: { title: '联系电话', order: 2, view: 'text', type: 'string' },
  bankAccount: { title: '银行账户', order: 3, view: 'text', type: 'string' },
  remarks: { title: '备注', order: 4, view: 'textarea', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
